home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5459 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  68 lines

  1. Newsgroups: comp.lang.c++
  2. Path: news3.noc.netcom.net!zdc!zippo!usenet
  3. From: txwang@public.sta.net.cn (Wang)
  4. Subject: Re: pInt = new int [987654321L], what will ha
  5. X-Newsreader: Forte Free Agent 1.0.82
  6. Sender: usenet@news.zippo.com
  7. Nntp-Posting-Host: ts1-15.sta.net.cn
  8. Organization: No Organization
  9. Message-ID: <DM9z8w.4Fz@news.zippo.com>
  10. References: <Pine.SOL.3.91.960203215559.25805E-100000@hamlet.uncg.edu> <31146e4c.197257088@nntp.ix.netcom.com> <Pine.SOL.3.91.960204100529.12786A-100000@hamlet.uncg.edu>
  11. Date: Sun, 4 Feb 1996 23:42:54 GMT
  12.  
  13. "QIAN . ZHONG" <q_zhong@hamlet.uncg.edu> wrote:
  14.  
  15. | On Sun, 4 Feb 1996, Mike Rubenstein wrote:
  16.  
  17. | > "QIAN . ZHONG" <q_zhong@hamlet.uncg.edu> wrote:
  18. | > 
  19. | > > 
  20. | > > Hi, folks:
  21. | > > 
  22. | > > Here is a question about new, the following is my code:
  23. | > > 
  24. | > > int main(void)
  25. | > > {
  26. | > >     int *pInt;
  27. | > >     long Block = 987654321L;
  28. | > > 
  29. | > >     pInt = new int[Block];
  30. | > >     if(pInt == NULL) dosomething();
  31. | > > }
  32. | > > 
  33. | > > My problem is when I compile the program for DOS under large memory 
  34. | > > model, above new nerve return NULL, I guess compiler convert
  35. | > > 
  36. | > > new int[987654321L] --- convert --> new int[ ACONST]
  37. | > > where ACONST = 0xffff , or ACONST = 0x7fff, am I right ?
  38. | > > Is this a DOS thing ? or a C++ thing ? Is this portable ?
  39. | > 
  40. | > More likely the system just doesn't have 987 meg free memory, so it
  41. | > can't do the allocation.  Newer compilers will throw an exception, but
  42. | > older ones simply return the null pointer.
  43. | > 
  44. | > 
  45. | > Michael M Rubenstein
  46. | > 
  47. | > 
  48. | Hi, Michael:
  49.  
  50. | Thanks for your message, my real problem is the compiler will not return a
  51. | null pointer, even if I set_new_handler(0);
  52.  
  53. | I am confused. Please help me again. I use BC++ 4.0.
  54.  
  55. | Qian
  56.  
  57. In DOS real mode, 987654321L may be converted to an unsigned int:
  58.  
  59.     (unsigned int)987654321L == 26801
  60.  
  61. So, you are allocating 26801 * sizeof(int) == 52602 bytes of memory.
  62. If you still have plenty of memory, you'll get a good pointer.
  63.  
  64. --
  65. Wang TianXing
  66.  
  67.  
  68.